import type { App } from 'vue'
import * as epIconsVue from '@element-plus/icons-vue'
import * as adIconsVue from '@ant-design/icons-vue'

// ant-design 图标不需要注册key
const adIconsNeedless = ['createFromIconfontCN', 'default', 'getTwoToneColor', 'setTwoToneColor']
// ant-design 图标 key 集合
const adIconKeys = []

// element-plus 图标 key 集合
const epIconKeys = []

// 注册所有图标
export function setupElIcons(app: App) {
  for (const [key, component] of Object.entries(epIconsVue)) {
    const epKey = `ep-${key}`
    epIconKeys.push(epKey)
    app.component(epKey, component)
  }
  for (const [key, component] of Object.entries(adIconsVue)) {
    if (!adIconsNeedless.includes(key) && !key.endsWith('TwoTone')) {
      const adKey = `ad-${key}`
      adIconKeys.push(adKey)
      app.component(adKey, component)
    }
  }
  app.config.globalProperties.$epIconKeys = epIconKeys
  app.config.globalProperties.$adIconKeys = adIconKeys
}
